package com.chixing.day09_innerclass.order;

public class OrderProcessUtil {
    /**
     * 实现【通用】订单处理
     */
    public static  Order[] process(Order order){ // 个人订单对象 Order order = new  PersonalOrder()
        int newLength = (int) ( Math.ceil((double)order.getProductCount()/1000) );


        Order[] orders= new Order[ newLength ];
        int count =0;
        // 2500 = 1000+1000+500
       while(order.getProductCount()>1000){
           Order subOrder = order.orderClone();  //【通用】 (1)new 订单对象 (2) 属性 = 原始订单属性
           subOrder.setProductCount(1000);
           order.setProductCount(order.getProductCount()-1000);
           orders[count++] = subOrder;
       }
       orders[count] = order;

        return orders;
    }

}
